package com.ruoyi.work.controller;

import java.util.List;
import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.collections4.Get;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.work.domain.BmSellermechanism;
import com.ruoyi.work.service.IBmSellermechanismService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 客户关系管理Controller
 * 
 * @author sj
 * @date 2023-08-02
 */
@RestController
@RequestMapping("/sellermechanism")
public class BmSellermechanismController extends BaseController
{
    @Autowired
    private IBmSellermechanismService bmSellermechanismService;

    /**
     * 导出客户关系管理列表
     */
    @RequiresPermissions("work:sellermechanism:export")
    @Log(title = "客户关系管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BmSellermechanism bmSellermechanism)
    {
        List<BmSellermechanism> list = bmSellermechanismService.selectBmSellermechanismList(bmSellermechanism);
        ExcelUtil<BmSellermechanism> util = new ExcelUtil<BmSellermechanism>(BmSellermechanism.class);
        util.exportExcel(response, list, "客户关系管理数据");
    }

    /**
     * 新增客户关系管理
     */
    @RequiresPermissions("work:sellermechanism:add")
    @Log(title = "客户关系管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BmSellermechanism bmSellermechanism)
    {
        return toAjax(bmSellermechanismService.insertBmSellermechanism(bmSellermechanism));
    }

    /**
     * 删除客户关系管理
     */
    @RequiresPermissions("work:sellermechanism:remove")
    @Log(title = "客户关系管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bmSellermechanismService.deleteBmSellermechanismByIds(ids));
    }



    @RequiresPermissions("work:sellermechanism:listBm")
    @GetMapping("/listBm")
    public TableDataInfo listBm(BmSellermechanism bmSellermechanism)
    {
        startPage();
        List<Map<String,Object>> list = bmSellermechanismService.listSellermechanism(bmSellermechanism);
        return getDataTable(list);
    }
    @RequiresPermissions("work:sellermechanism:getBusinessName")
    @GetMapping("/getBusinessName")
    public TableDataInfo getBusinessName(){
        return getDataTable(bmSellermechanismService.getBusinessName());
    }
    @RequiresPermissions("work:sellermechanism:getMechanismName")
    @GetMapping("/getMechanismName")
    public TableDataInfo getMechanismName(){
        return getDataTable(bmSellermechanismService.getMechanismName());
    }
}
